package object2;

/**
 * 面向对象编程(中级部分)练习
 */
public class Object2Exercise05 {

    public static void main(String[] args) {

        /*
            假定Grand、 Fathers和Sons在同一个包，问：父类和子类中通过this和super都可以调用哪些属性和方法
         */
    }
}

class Grand {

    String name = "AA";

    private int age = 100;

    public void g1() {

    }
}

class Fathers extends Grand {

    String id = "001";

    private double score;

    public void f1() {
        //super可以访问哪些成员(属性和方法)
        String name = super.name;
        super.g1();
        //this可以访问哪些成员
        String id = this.id;
        this.f1();
        String name1 = this.name;
        this.g1();
    }
}

class Sons extends Fathers {

    String name = "BB";

    public void g1() {

    }

    private void show() {

        //super可以访问哪些成员(属性和方法)
        String id = super.id;
        super.f1();
        String name = super.name;
        super.g1();

        //this可以访问哪些成员
        String name1 = this.name;
        this.g1();
        this.show();
        String id1 = this.id;
        this.f1();
    }
}